<extend name="./common" />
  <block name="content">
  <div class="content-wrap"><!--内容-->
    <div class="content">
      <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> <!--banner-->
        <ol class="carousel-indicators">
        <?php
            foreach($bannerArticle as $k=>$ba){
              if($k!=0){
              echo '<li data-target="#carousel-example-generic" data-slide-to="'.$k.'"></li>';
              }else{
                        echo '<li data-target="#carousel-example-generic" data-slide-to="'.$k.'" class="active"></li>';
              }
            }
          ?>
        </ol>
        <div class="carousel-inner" role="listbox">
        <?php
            foreach($bannerArticle as $k=>$ba){
              if($k!=0){
              echo '<div class="item"> <a href="'.U('index/article/id/'.$ba['id']).'" target="_blank"><img src="'.$ba['banner'].'" alt="'.$ba['title'].' " /></a>
            <div class="carousel-caption"> '.$ba['title'].' </div>
            <span class="carousel-bg"></span> </div>';
              }else{
                        echo '<div class="item active"> <a href="'.U('index/article/id/'.$ba['id']).'" target="_blank"><img src="'.$ba['banner'].'" alt="'.$ba['title'].' " /></a>
            <div class="carousel-caption"> '.$ba['title'].' </div>
            <span class="carousel-bg"></span> </div>';
              }
            }
          ?>
        </div>
        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> 
        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div>
      <!--/banner-->
      <div class="content-block hot-content hidden-xs">
        <h2 class="title"><strong>本周热门排行</strong></h2>
        <ul>
          <?php
            foreach($weekHot as $k=>$wh){
              if(!empty($wh['cover']) && file_exists('.'.$wh['cover'])){
                $cover= $wh['cover'];
              }else{
                $cover="__PUBLIC__/static/admin/i/1.jpg";
              }
              if($k!=0){
                echo "<li><a href='".U('index/article/id/'.$wh['id'])."' target='_blank'><img src='".$cover."' alt='".$wh['title']."'><h3>".$wh['title']." </h3></a></li>";
              }else{
                echo "<li class='large'><a href='".U('index/article/id/'.$wh['id'])."' target='_blank'><img src='".$cover."' alt='".$wh['title']."'><h3>".$wh['title']." </h3></a></li>";
              }
            }
          ?>
        </ul>
      </div>
      <div class="content-block new-content">
        <h2 class="title"><strong>最新文章</strong></h2>
        <div class="row">
        <foreach name='newArticles' item='a'>
          <div class="news-list">
            <div class="news-img col-xs-5 col-sm-5 col-md-4"> <a target="_blank" href="{:U('index/article/id/'.$a['id'])}"><img <empty name='a.cover'>src='__PUBLIC__/static/admin/i/1.jpg'<else /> src="
            <?php
              if(file_exists('.'.$a['cover'])){
                echo $a['cover'];
              }else{
                echo "__PUBLIC__/static/admin/i/1.jpg";
              }
            ;?>
            "</empty> alt="{$a['title']}的封面图"> </a> </div>
            <div class="news-info col-xs-7 col-sm-7 col-md-8">
              <dl>
                <dt><a href="{:U('index/article/id/'.$a['id'])}" target="_blank" > {$a['title']} </a> </dt>
                <dd>
                <span class="name"><a href="{:U('index/about')}" title="由 {:F('webSet')['webtitle']}-{$user} 发布" rel="author">{$user}</a></span> <span class="identity"></span>
                 <span class="time"> {$a['create_time']|date='Y-m-d H:i:s',###} </span>
                 </dd>
                <dd class="text"><?php echo mb_substr(trim(strip_tags(htmlspecialchars_decode($a['content']))),0,120,'utf-8') ;?>...</dd>
              </dl>
              <div class="news_bot col-sm-7 col-md-8"> 
              <span class="tags visible-lg visible-md">
              标签： 
              <?php 
                  $tags=explode(',',$a['tags']);
                  foreach($tags as $tag){
                    echo "<a href='".U('index/articles/tag/'.$tag)."'>$tag</a>";
                  }
              ?>
                </span>
                <span class="tags visible-lg visible-md">
                分类：
                <a href="{:U('index/articles/cid/'.$a['category_id'])}">{$a['category']}</a></span>
                 <span class="look"> 共 <strong>{$a['views']}</strong> 人围观， <strong> {$a['likes']} </strong> 人喜欢 </span> </div>
            </div>
          </div>
          </foreach>
        </div>
        <span style="display: none" id="nextpage">2</span>
            </div> 
    </div>
  </div>
  </block>

  <block name='js'>
  <script src="__PUBLIC__/static/home/js/jquery.lazyload.min.js"></script>
  <script type="text/javascript">
    //滚动条到页面底部加载更多案例 
    $(window).scroll(function(){
      var scrollTop = $(this).scrollTop();    //滚动条距离顶部的高度
      var scrollHeight = $(document).height();   //当前页面的总高度
      var clientHeight = $(this).height();    //当前可视的页面高度
      if(scrollTop + clientHeight >= scrollHeight){ 
        /*翻页*/
        var page=$('#nextpage').text();
        next(page);
      }else if(scrollTop<=0){ 

      }
    });
    flag=true;
    function next (p){
      if (p > {$pageCount}){
        if(flag){
          var foot='<hr><h5 style="text-align:center;color:#aaa;line-height:40px">---我是有底线的---</h5>';
          $(".row").append($(foot).fadeIn(400));
          flag=false;
        }
        return false;
      }
      // layer.msg('请稍等，正在加载...');
      var _url = window.location+'?p='+p;
      if (p <= {$pageCount}){
        $('#nextpage').text(parseInt(p)+1);
      }
      jQuery.ajax({
        type : "POST",
        url : _url,
        success : function (data){
          //将返回的数据进行处理，挑选出class是news-list的内容块
          result = jQuery(data).find(".row .news-list");
          // 渐显新内容
          jQuery(function (){
            jQuery(".row").append(result.fadeIn(300));
            jQuery("img").lazyload({
              effect : "fadeIn"
            });
            layer.closeAll();
          });
        }
      });
    }
  </script>
  </block>